import pymysql

class database:
    def __init__(self):
        self.host = '202.115.157.20'
        self.port = 4000
        self.user = 'root'
        self.password = 'U0-gEZ_Jy5829WB*+7'
        self.database = 'xyibanng'
        self.charset = 'utf8'

    def connection(self):
        # 建立数据库连接
        conn = pymysql.connect(
            host=self.host,  # 数据库主机地址
            port=self.port,
            user=self.user,  # 数据库用户名
            password=self.password,  # 数据库密码
            database=self.database,  # 数据库名称
            charset=self.charset
        )
        return conn
